Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optimization technique related validations. #4921

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

cj-zhang
Copy link
Contributor

@cj-zhang cj-zhang commented Nov 8, 2024

Description of changes:

  • Enable quantization and compilation in the same optimization job via ModelBuilder and add validations to block compilation jobs using TRTLLM and Llama-3.1. (revisions needed here, validations are outdated: https://github.com/aws/sagemaker-python-sdk/pull/4875/commits)
  • Require EULA acceptance when using a gated 1p draft model via ModelBuilder. (optimize() and deploy() wrapper)
  • Require EULA acceptance when using a gated 1p draft model via JumpStartModel constructor + set_deployment_config() + ModelBuilder.set_deployment_config()

Testing done:

  • Calling ModelBuilder.optimize() w/speculative_decoding_config set to use 1p gated draft model triggers validation when AcceptEula is false, and sets the data source ModelAccessConfig to True when EULA is accepted
  • Called ModelBuilder.set_deployment_config(config_name, instance_type, accept_draft_model_eula), JumpStart(config_name, instance_type, accept_draft_model_eula), JumpStart.set_deployment_config(config_name, instance_type, accept_draft_model_eula) to verify all functionality
  • UTs are not working locally. Monitoring them via the checks in this PR.

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • I have read the CONTRIBUTING doc
  • I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • I have checked that my tests are not configured for a specific region or account (if appropriate)
  • I have used unique_name_from_base to create resource names in integ tests (if appropriate)
  • If adding any dependency in requirements.txt files, I have spell checked and ensured they exist in PyPi

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Joseph Zhang added 2 commits November 7, 2024 11:37
…ModelBuilder and add validations to block compilation jobs using TRTLLM an Llama-3.1.
@gwang111 gwang111 requested review from Lokiiiiii and removed request for nileshvd November 8, 2024 04:13
Copy link
Contributor

@Lokiiiiii Lokiiiiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me how users can provide a JS model as a draft model in ModelBuilder.optimize . Can you please provide an example and what happens in the case of a gated draft model ?

return additional_model_data_source.get("S3DataSource").get("S3Uri", None)


def _extract_deployment_config_additional_model_data_source_s3_uri(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of _extract_additional_model_data_source_s3_uri ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployment config uses Pascal case while the PySDK model will use snake case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

ToDo: We need to find a different way of closing these differences.

src/sagemaker/serve/utils/optimize_utils.py Outdated Show resolved Hide resolved

if not accept_eula:
raise ValueError(
"Gated draft model requires accepting end-user license agreement (EULA)."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a note on how the user can do this. Eg: Set parameter to true.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can re-use messaging from jumpstart.factory.model
Consider re-using that through a helper function.

src/sagemaker/serve/utils/optimize_utils.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/factory/model.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/factory/model.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/model.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/model.py Outdated Show resolved Hide resolved
…ployment_config flow validation in optimize_utils in favor of the one directly on jumpstart/factory/model.
Copy link
Contributor

@Lokiiiiii Lokiiiiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 recent commits look good ! I would like to see more tests once the local issues are fixed.

@Lokiiiiii
Copy link
Contributor

What is the behavior when a customer provides a SpeculativeDecodingConfig with "SageMaker" as model provider for a JS llama-3.1-70B model ?

… to differentiate SageMaker/JumpStart draft models.
@cj-zhang
Copy link
Contributor Author

What is the behavior when a customer provides a SpeculativeDecodingConfig with "SageMaker" as model provider for a JS llama-3.1-70B model ?

Commit d10c475 introduces a ValueError when a proprietary SM draft model can't be found, and recommends the customer to try using Auto.

@JGuinegagne JGuinegagne changed the title Add optimization technique related validations. feat: optimization technique related validations. Nov 13, 2024
Copy link
Contributor

@JGuinegagne JGuinegagne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unit test coverage for jumpstart construct changes in the PySDK.

src/sagemaker/jumpstart/model.py Show resolved Hide resolved
src/sagemaker/jumpstart/model.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/types.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/utils.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/utils.py Outdated Show resolved Hide resolved
src/sagemaker/serve/builder/jumpstart_builder.py Outdated Show resolved Hide resolved
src/sagemaker/serve/utils/optimize_utils.py Show resolved Hide resolved
src/sagemaker/serve/utils/optimize_utils.py Outdated Show resolved Hide resolved
src/sagemaker/serve/utils/optimize_utils.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/utils.py Outdated Show resolved Hide resolved
zhaoqizqwang
zhaoqizqwang previously approved these changes Nov 15, 2024
JGuinegagne
JGuinegagne previously approved these changes Nov 15, 2024
src/sagemaker/jumpstart/model.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/model.py Outdated Show resolved Hide resolved
src/sagemaker/jumpstart/utils.py Outdated Show resolved Hide resolved
tests/unit/sagemaker/jumpstart/test_utils.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants